package com.qianyu.project.mapper.provider.smj;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.util.ObjectUtils;

import java.util.Map;

public class smjLaberApplyProvider {
    //查看劳务付款列表
    public String listLaberApply(IPage<Map<String, Object>> page, Map<String, String> params){
        return new SQL(){
            {
                SELECT("app.*,b.*,pi.project_name ,pi2.provider_name ,lc.contract_name,lc.advance_pay");
                FROM("apply_labor_payment app");
                LEFT_OUTER_JOIN("labor_contract lc on app.ctr_id=lc.id ");
                LEFT_OUTER_JOIN("project_info pi on app.p_id=pi.id ");
                LEFT_OUTER_JOIN("provider_info pi2 on app.company_id = pi2.id ");
                LEFT_OUTER_JOIN("bank b on app.bank_id = b.bank_id ");
                if(!ObjectUtils.isEmpty(params.get("id"))){
                    WHERE("app.id ='"+params.get("id")+"'");
                }
                if(!ObjectUtils.isEmpty(params.get("payment_name"))){
                    WHERE("app.payment_name ='"+params.get("payment_name")+"'");
                }
                if(!ObjectUtils.isEmpty(params.get("agree_amount"))){
                    WHERE("app.agree_amount >='"+params.get("agree_amount")+"'");
                }
                if(!ObjectUtils.isEmpty(params.get("agree_amount2"))){
                    WHERE("app.agree_amount <='"+params.get("agree_amount2")+"'");
                }
                if(!ObjectUtils.isEmpty(params.get("handler_id"))){
                    WHERE("app.handler_id ='"+params.get("handler_id")+"'");
                }
                if(!ObjectUtils.isEmpty(params.get("laberId"))){
                    WHERE("app.ctr_id ='"+params.get("laberId")+"'");
                }
                if(!ObjectUtils.isEmpty(params.get("projectId"))){
                    WHERE("app.p_id ='"+params.get("projectId")+"'");
                }
                if(!ObjectUtils.isEmpty(params.get("providerId"))){
                    WHERE("app.company_id ='"+params.get("providerId")+"'");
                }
                if(!ObjectUtils.isEmpty(params.get("start_date"))){
                    WHERE("app.apply_date >='"+params.get("start_date")+"'");
                }
                if(!ObjectUtils.isEmpty(params.get("end_date"))){
                    WHERE("app.apply_date <='"+params.get("end_date")+"'");
                }
                if(!ObjectUtils.isEmpty(params.get("approve_status"))){
                    WHERE("app.approve_status ='"+params.get("approve_status")+"'");
                }
            }
        }.toString();
    }
}
